package view;




import java.math.*;

class EEC{
	private BigInteger p,q;
//	private BigInteger p,q;
	private BigInteger a,b,d;
	private BigInteger x1,x2,y1,y2,t1,t2;
	
	public EEC(BigInteger pin, BigInteger qin){
		p = pin;
		q = qin;
		}
		
	public void compute(){
		if (q.equals(BigInteger.valueOf(0))) {
			d = p;
			a = BigInteger.valueOf(1);
			b = BigInteger.valueOf(0);
			} else {
			x2 = BigInteger.valueOf(1);
			x1 = BigInteger.valueOf(0);
			y2 = BigInteger.valueOf(0);
			y1 = BigInteger.valueOf(1);
			while(q.compareTo(BigInteger.valueOf(0)) > 0){
				t1 = p.divide(q);
				t2 = p.add((t1.multiply(q)).negate());
				a = x2.add((t1.multiply(x1)).negate());
				b = y2.add((t1.multiply(y1)).negate());
				p = q;
				q = t2;
				x2 = x1;
				x1 = a;
				y2 = y1;
				y1 = b;
				}
				
			d = p;
			a = x2;
			b = y2;
			}
		}
		
	public BigInteger getD(){
		return d;
		}
		
	public BigInteger getA(){
		return a;
		}

	public BigInteger getB(){
		return b;
		}				
		
}
